package br.com.dyad.commons.data;

import java.util.HashMap;
import java.util.List;

public abstract class AppTransaction {
	
	private String database;
	
	private Long transactionNumber;
		
	public Long getTransactionNumber() {
		return transactionNumber;
	}
	
	public void setTransactionNumber(Long transactionNumber) {
		this.transactionNumber = transactionNumber;
	}
	
	public String getDatabase() {
		return database;
	}

	public void setDatabase(String database) {
		this.database = database;
	}

	public abstract Object getSession();
	
	public abstract void save(AppEntity appEntity);
	public abstract void delete(AppEntity appEntity);
	public abstract Long commit();
	public abstract void rollback();
	public abstract void beginTransaction() throws Exception;
	@SuppressWarnings("unchecked")
	public abstract List<Object> executeQuery(String query);
	public abstract List<Object> executeQuery(String query, int offset, int maxResults);
	/**
	 * Executa uma query com parâmetros
	 * Obs: os parâmetros serão setados na ordem que estão na lista
	 */
	public abstract List<Object> executeQuery(String query, List<Object> params);
	
	/**
	 * Caso aconteça algum erro na transação, este método deve ser chamado
	 * 
	 * @author eduardo
	 */
	public abstract void clear();

}
